'''
@since: 21.03.2014

@author: Max
@summary: Die Klasse Tileset laed ein Image-File, welches dann in ein Array gespeichert wird. Bspw. werden hierdurch Resourcen fuer Maps, Player-Models etc. geladen
'''

from pygame import Rect
import pygame

from Properties import *    # @UnusedWildImport


class Tileset(object):
    def __init__(self, filePath):
        self.image = pygame.image.load(filePath).convert_alpha()
        """@ivar: Enthaelt das komplett geladene Bild"""
        
        self.arTileImages = []
        """@ivar: Array mit allen Tile-Images"""
        
        self.buildUpArray()
        
    def buildUpArray(self):
        for row in range(self.image.get_height() // TILESET_TILE_HEIGHT):
            for col in range(self.image.get_width() // TILESET_TILE_WIDTH):
                pos = Rect(col * TILESET_TILE_WIDTH,
                           row * TILESET_TILE_HEIGHT,
                           TILESET_TILE_WIDTH,
                           TILESET_TILE_HEIGHT)
                self.arTileImages.append(self.image.subsurface(pos))
                
    def getTile(self, getID):
        return self.arTileImages[getID]
                
                
        
        
        
        
